var cb = require("./13_cb");
var forEach = require("./16_forEach");

function filter(array, predicate, context) {
  predicate = cb(predicate, context);
  var result = [];
  forEach(array, function (value, index) {
    if (predicate(value, index, array)) {
      result.push(value);
    }
  });
  return result;
}

module.exports = filter;
